// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------
// Modification history:
// feature: Code style modification
// ------------------------------------------------------------------

#ifndef XMLPARSER_DATA_READERPROXYDATA_H_
#define XMLPARSER_DATA_READERPROXYDATA_H_

#include <xmlparser/qos/XMLReaderQos.hpp>
#include <xmlparser/attributes/XMLRTPSParticipantAllocationAttributes.hpp>
#include <xmlparser/xmlutils/RemoteLocators.hpp>
#include <deps/common/Guid.h>
#include <ostream>

namespace vbsutil {
namespace xmlparser {

/**
 * Class ReaderProxyDataPart, used to represent all the information on a Reader (both local and remote)
 * with the purpose of implementing the discovery.
 * *@ingroup BUILTIN_MODULE
 */
class ReaderProxyDataPart {
 public:
    ReaderProxyDataPart();

    ReaderProxyDataPart(const ReaderProxyDataPart& readerInfo);

    ReaderProxyDataPart& operator=(const ReaderProxyDataPart& readerInfo);

    RTPS_DllAPI ReaderProxyDataPart(const size_t max_unicast_locators, const size_t max_multicast_locators);

    RTPS_DllAPI virtual ~ReaderProxyDataPart();

    RTPS_DllAPI void userDefinedId(uint16_t userDefinedId) { m_userDefinedId = userDefinedId; }

    RTPS_DllAPI GUID_t& guid() { return m_guid; }

    RTPS_DllAPI const RemoteLocatorList& remote_locators() const { return remote_locators_; }

    RTPS_DllAPI bool has_locators() const {
        return (!remote_locators_.unicast.empty()) || (!remote_locators_.multicast.empty());
    }

    RTPS_DllAPI void topicName(const string_255& topicName) { m_topicName = topicName; }

    RTPS_DllAPI void topicName(string_255&& topicName) { m_topicName = std::move(topicName); }

    RTPS_DllAPI string_255& topicName() { return m_topicName; }

    RTPS_DllAPI const string_255& topicName() const { return m_topicName; }

    RTPS_DllAPI void typeName(const string_255& typeName) { m_typeName = typeName; }

    RTPS_DllAPI const string_255& typeName() const { return m_typeName; }

    RTPS_DllAPI string_255& typeName() { return m_typeName; }

    RTPS_DllAPI void topicKind(TopicKind_t topicKind) { m_topicKind = topicKind; }

    RTPS_DllAPI TopicKind_t& topicKind() { return m_topicKind; }

    RTPS_DllAPI uint16_t userDefinedId() const { return m_userDefinedId; }

    RTPS_DllAPI uint16_t& userDefinedId() { return m_userDefinedId; }

    RTPS_DllAPI void add_unicast_locator(const Locator_t& locator);

    RTPS_DllAPI void add_multicast_locator(const Locator_t& locator);

    RTPS_DllAPI void isAlive(bool isAlive) { m_isAlive = isAlive; }

    RTPS_DllAPI bool isAlive() const { return m_isAlive; }

    RTPS_DllAPI bool& isAlive() { return m_isAlive; }

    friend std::ostream& operator<<(std::ostream& os, const ReaderProxyDataPart& data);

    ReaderQos m_qos;

    size_t unicast_locators_size;

    size_t multicast_locators_size;

 private:
    RemoteLocatorList remote_locators_;

    string_255 m_typeName;

    string_255 m_topicName;

    uint16_t m_userDefinedId;

    GUID_t m_guid;

    bool m_isAlive;

    TopicKind_t m_topicKind;
};

}  // namespace xmlparser
}  // namespace vbsutil

#endif
